<template>
    <n-menu
          :options="menuOptions"
    />
</template>

<script>
import { RouterLink } from 'vue-router'
import { h } from 'vue'
export default {
    name: 'Navigator',
    computed: {
        menuOptions() {
            const identity = this.$store.state.identity
            if(identity === 'school') {
                return [
                    {
                        label: '管理学生',
                        key: 'manage-student',
                        children: [
                            {
                                label: () =>
                                    h(
                                        RouterLink, 
                                        {
                                            to: {
                                                name: 'addStudent'
                                            }
                                        },
                                        {default: () => '添加学生'}
                                    ),
                                key: 'add-student'
                            },
                            {
                                label: () =>
                                    h(
                                        RouterLink,
                                        {
                                            to: {
                                                name: 'showStudent'
                                            }
                                        },
                                        {default: () => '查看学生'}
                                    ),
                                key: 'show-student'
                            },
                        ]
                    },
                    {
                        label: '管理证书',
                        key: 'manage-credential',
                        children: [
                            {
                                label: () =>
                                    h(
                                        RouterLink,
                                        {
                                            to: {
                                                name: 'addGrade'
                                            }
                                        },
                                        {default: () => '添加成绩'}
                                    ),
                                key: 'add-grade'
                            },
                            {
                                label: () =>
                                    h(
                                        RouterLink,
                                        {
                                            to: {
                                                name: 'enrollment',
                                                params: {
                                                    isAdd: true
                                                }
                                            }
                                        },
                                        {default: () => '添加学籍'}
                                    ),
                                key: 'add-enrollment'
                            },
                        ]
                    }
                ]
            } else if(identity === 'student') {
                return [
                    {
                        label: () =>
                            h(
                                RouterLink,
                                {
                                    to: {
                                        name: 'enrollment',
                                        params: {
                                            studentNumber: this.$store.state.username
                                        }
                                    }
                                },
                                {default: () => '查询学籍'}
                            ),
                        key: 'query-enrollment'
                    },
                    {
                        label: () =>
                            h(
                                RouterLink,
                                {
                                    to: {
                                        name: 'queryGrade'
                                    }
                                },
                                {default: () => '查询成绩'}
                            ),
                        key: 'query-grade'
                    }
                ]
            } else if(identity === 'enterprise'){
                return [
                    {
                        label: () =>
                            h(
                                RouterLink,
                                {
                                    to: {
                                        name: 'verify',
                                        params: {
                                            type: 'Enrollment'
                                        }
                                    }
                                },
                                {default: () => '验证学籍'}
                            ),
                        key: 'verifyEnrollment'
                    },
                    {
                        label: () =>
                            h(
                                RouterLink,
                                {
                                    to: {
                                        name: 'verify',
                                        params: {
                                            type: 'Grade'
                                        }
                                    }
                                },
                                {default: () => '验证成绩'}
                            ),
                        key: 'verifyGrade'
                    }
                ]
            } else {
                return [
                    {
                        label: () =>
                            h(
                                RouterLink,
                                {
                                    to: {
                                        name: 'addSchool'
                                    }
                                },
                                { default: () => '添加学校'}
                            ),
                        key: 'addSchool'
                    },
                    {
                        label: () =>
                            h(
                                RouterLink,
                                {
                                    to: {
                                        name: 'addEnterprise'
                                    }
                                },
                                { default: () => '添加企业'}
                            ),
                        key: 'addEnterprise'
                    },
                    {
                        label: () =>
                            h(
                                RouterLink,
                                {
                                    to: {
                                        name: 'schools'
                                    }
                                },
                                { default: () => '管理学校'}
                            ),
                        key: 'schools'
                    },
                    {
                        label: () =>
                            h(
                                RouterLink,
                                {
                                    to: {
                                        name: 'enterprises'
                                    }
                                },
                                { default: () => '管理企业'}
                            ),
                        key: 'enterprises'
                    }
                ]
            }
        }
    }
}
</script>

<style scoped>

</style>

<style lang="less">
.n-menu .n-menu-item-content .n-menu-item-content-header{
    font-size: 20px;
    a {
        font-size: 20px;
    }
}
</style>
